package com.zhaowb.springcloud.common.util.jwt;

import java.io.Serializable;
import java.util.Objects;

/**
 * Created with IDEA
 * 用户信息
 *
 * @author zhaowb
 * @date 2018/10/24 14:04
 */
public class JWTInfo implements Serializable, IJWTInfo {
    /**
     * 用户名
     */
    private String username;
    /**
     * 用户ID
     */
    private String userId;
    /**
     * 用户名称
     */
    private String name;


    public JWTInfo(String username, String userId, String name) {
        this.username = username;
        this.userId = userId;
        this.name = name;
    }

    @Override
    public String getUniqueName() {
        return username;
    }

    @Override
    public String getUserId() {
        return userId;
    }

    @Override
    public String getName() {
        return name;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        JWTInfo jwtInfo = (JWTInfo) o;
        return Objects.equals(username, jwtInfo.username) &&
                Objects.equals(userId, jwtInfo.userId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, userId);
    }
}
